package com.pdsu.graduation_design.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.pdsu.graduation_design.R;
import com.pdsu.graduation_design.dto.CommodityLikeDTO;
import com.squareup.picasso.Picasso;

import java.util.List;

public class MyLikeCommodityAdapter extends BaseAdapter {


    private Context context;
    private List<CommodityLikeDTO> commodityLikeDTOS;

    private TextView cname,cprice,username;
    private ImageView image;

    public MyLikeCommodityAdapter(Context context, List<CommodityLikeDTO> commodityLikeDTOS) {
        this.context = context;
        this.commodityLikeDTOS = commodityLikeDTOS;
    }

    @Override
    public int getCount() {
        return commodityLikeDTOS.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View view=View.inflate(context, R.layout.activity_main_grid_view_item_detail_item,null);

        cname=view.findViewById(R.id.activity_main_listview_item_title);
        image=view.findViewById(R.id.activity_main_listview_item_image);
        username=view.findViewById(R.id.activity_main_listview_item_username_tv);
        cprice=view.findViewById(R.id.activity_main_listview_item_price);
        cprice.setText(commodityLikeDTOS.get(position).getPrice());
        cname.setText(commodityLikeDTOS.get(position).getCname());
        username.setText(commodityLikeDTOS.get(position).getUsername());
        Picasso.with(context).load(commodityLikeDTOS.get(position).getImage()).into(image);

        return view;
    }
}
